{% extends 'base.html' %}

{% block title %}我的领养申请{% endblock %}

{% block content %}
<h2 class="mb-4">我的领养申请</h2>

{% if applications %}
<div class="card">
    <div class="table-responsive">
        <table class="table table-hover mb-0">
            <thead class="table-light">
                <tr>
                    <th>宠物名称</th>
                    <th>申请时间</th>
                    <th>申请状态</th>
                    <th>审核回复</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for app in applications %}
                <tr>
                    <td>
                        <a href="{% url 'pet_detail' app.pet.id %}" class="text-primary">{{ app.pet.name }}</a>
                    </td>
                    <td>{{ app.created_time|date:"Y-m-d H:i" }}</td>
                    <td>
                        {% if app.status == 'pending' %}
                            <span class="badge bg-warning">待审核</span>
                        {% elif app.status == 'approved' %}
                            <span class="badge bg-success">已通过</span>
                        {% else %}
                            <span class="badge bg-danger">未通过</span>
                        {% endif %}
                    </td>
                    <td>
                        {% if app.reply %}
                            {{ app.reply }}
                        {% else %}
                            <span class="text-muted">暂无回复</span>
                        {% endif %}
                    </td>
                    <td>
                        {% if app.status == 'pending' %}
                            <button class="btn btn-sm btn-secondary" disabled>审核中</button>
                        {% else %}
                            <a href="{% url 'pet_list' %}" class="btn btn-sm btn-primary">查看其他宠物</a>
                        {% endif %}
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% else %}
<div class="alert alert-info" role="alert">
    <h4 class="alert-heading">暂无领养申请</h4>
    <p>你还没有提交过领养申请，快去浏览可领养宠物吧！</p>
    <hr>
    <a href="{% url 'pet_list' %}" class="btn btn-primary">前往宠物列表</a>
</div>
{% endif %}
{% endblock %}